Building an RPG with Unity 5.x by 2016
Author:2016
Language: eng
Format: mobi
Publisher: Packt Publishing
Character customization class update
The events that drive the character customization are attached to the Base prefab, which has the CharacterCustomization.cs script as a component. The CharacterCustomization.cs script is listed here:
using UnityEngine; using UnityEngine.UI; using System.Collections; using UnityEngine.SceneManagement; using System; public class CharacterCustomization : MonoBehaviour { // reference to PC Game Object public GameObject PLAYER_CHARACTER; // variable used to hold the PC Customization public PC PC_CC; public Material[] PLAYER_SKIN; public GameObject CLOTH_01LOD0; public GameObject CLOTH_01LOD0_SKIN; public GameObject CLOTH_02LOD0; public GameObject CLOTH_02LOD0_SKIN; public GameObject CLOTH_03LOD0; public GameObject CLOTH_03LOD0_SKIN; public GameObject CLOTH_03LOD0_FAT; public GameObject BELT_LOD0; public GameObject SKN_LOD0; public GameObject FAT_LOD0; public GameObject RGL_LOD0; public GameObject HAIR_LOD0; public GameObject BOW_LOD0; // Head Equipment public GameObject GLADIATOR_01LOD0; public GameObject HELMET_01LOD0; public GameObject HELMET_02LOD0; public GameObject HELMET_03LOD0; public GameObject HELMET_04LOD0; // Shoulder Pad - Right Arm / Left Arm public GameObject SHOULDER_PAD_R_01LOD0; public GameObject SHOULDER_PAD_R_02LOD0; public GameObject SHOULDER_PAD_R_03LOD0; public GameObject SHOULDER_PAD_R_04LOD0; public GameObject SHOULDER_PAD_L_01LOD0; public GameObject SHOULDER_PAD_L_02LOD0; public GameObject SHOULDER_PAD_L_03LOD0; public GameObject SHOULDER_PAD_L_04LOD0; // Fore Arm - Right / Left Plates public GameObject ARM_PLATE_R_1LOD0; public GameObject ARM_PLATE_R_2LOD0; public GameObject ARM_PLATE_L_1LOD0; public GameObject ARM_PLATE_L_2LOD0; // Player Character Weapons public GameObject AXE_01LOD0; public GameObject AXE_02LOD0; public GameObject CLUB_01LOD0; public GameObject CLUB_02LOD0; public GameObject FALCHION_LOD0; public GameObject GLADIUS_LOD0; public GameObject MACE_LOD0; public GameObject MAUL_LOD0; public GameObject SCIMITAR_LOD0; public GameObject SPEAR_LOD0; public GameObject SWORD_BASTARD_LOD0; public GameObject SWORD_BOARD_01LOD0; public GameObject SWORD_SHORT_LOD0; // Player Character Defense Weapons public GameObject SHIELD_01LOD0; public GameObject SHIELD_02LOD0; public GameObject QUIVER_LOD0; public GameObject BOW_01_LOD0; // Player Character Calf - Right / Left public GameObject KNEE_PAD_R_LOD0; public GameObject LEG_PLATE_R_LOD0; public GameObject KNEE_PAD_L_LOD0; public GameObject LEG_PLATE_L_LOD0; public GameObject BOOT_01LOD0; public GameObject BOOT_02LOD0; // Use this for initialization void Start() { this.PC_CC = this.PLAYER_CHARACTER.GetComponent<PlayerAgent>().playerCharacterData; } public bool ROTATE_MODEL = false; // Update is called once per frame void Update() { if (Input.GetKeyUp(KeyCode.R)) { this.ROTATE_MODEL = !this.ROTATE_MODEL; } if (this.ROTATE_MODEL) { this.PLAYER_CHARACTER.transform.Rotate(new Vector3(0, 1, 0), 33.0f * Time.deltaTime); } if (Input.GetKeyUp(KeyCode.L)) { Debug.Log(PlayerPrefs.GetString("NAME")); } } public void SetShoulderPad(Toggle id) { try { PC.SHOULDER_PAD name = (PC.SHOULDER_PAD)Enum.Parse(typeof(PC.SHOULDER_PAD), id.name, true); if(id.isOn) { this.PC_CC.selectedShoulderPad = name; Debug.Log(string.Format("{0} was turned on", name)); } else { this.PC_CC.selectedShoulderPad = PC.SHOULDER_PAD.none; Debug.Log(string.Format("{0} was turned off", name)); } } catch { // if the value passed is not in the enumeration set it to none this.PC_CC.selectedShoulderPad = PC.SHOULDER_PAD.none; Debug.Log("Shoulder Pad Enumeration Not Found!"); } switch (id.name) { case "SP01": { this.SHOULDER_PAD_R_01LOD0.SetActive(id.isOn); this.SHOULDER_PAD_R_02LOD0.SetActive(false); this.SHOULDER_PAD_R_03LOD0.SetActive(false); this.SHOULDER_PAD_R_04LOD0.SetActive(false); this.SHOULDER_PAD_L_01LOD0.SetActive(id.isOn); this.SHOULDER_PAD_L_02LOD0.SetActive(false); this.SHOULDER_PAD_L_03LOD0.SetActive(false); this.SHOULDER_PAD_L_04LOD0.SetActive(false); break; } case "SP02": { this.SHOULDER_PAD_R_01LOD0.SetActive(false); this.SHOULDER_PAD_R_02LOD0.SetActive(id.isOn); this.SHOULDER_PAD_R_03LOD0.SetActive(false); this.SHOULDER_PAD_R_04LOD0.SetActive(false); this.SHOULDER_PAD_L_01LOD0.SetActive(false); this.SHOULDER_PAD_L_02LOD0.SetActive(id.isOn); this.SHOULDER_PAD_L_03LOD0.SetActive(false); this.SHOULDER_PAD_L_04LOD0.SetActive(false); break; } case "SP03": { this.SHOULDER_PAD_R_01LOD0.SetActive(false); this.SHOULDER_PAD_R_02LOD0.SetActive(false); this.SHOULDER_PAD_R_03LOD0.SetActive(id.isOn); this.SHOULDER_PAD_R_04LOD0.SetActive(false); this.SHOULDER_PAD_L_01LOD0.SetActive(false); this.SHOULDER_PAD_L_02LOD0.SetActive(false); this.SHOULDER_PAD_L_03LOD0.SetActive(id.isOn); this.SHOULDER_PAD_L_04LOD0.SetActive(false); break; } case "SP04": { this.SHOULDER_PAD_R_01LOD0.SetActive(false); this.SHOULDER_PAD_R_02LOD0.SetActive(false); this.SHOULDER_PAD_R_03LOD0.SetActive(false); this.SHOULDER_PAD_R_04LOD0.SetActive(id.isOn); this.SHOULDER_PAD_L_01LOD0.SetActive(false); this.SHOULDER_PAD_L_02LOD0.SetActive(false); this.SHOULDER_PAD_L_03LOD0.SetActive(false); this.SHOULDER_PAD_L_04LOD0.SetActive(id.isOn); break; } default: { this.SHOULDER_PAD_R_01LOD0.SetActive(false); this.SHOULDER_PAD_R_02LOD0.SetActive(false); this.SHOULDER_PAD_R_03LOD0.SetActive(false); this.SHOULDER_PAD_R_04LOD0.SetActive(false); this.SHOULDER_PAD_L_01LOD0.SetActive(false); this.SHOULDER_PAD_L_02LOD0.SetActive(false); this.SHOULDER_PAD_L_03LOD0.SetActive(false); this.SHOULDER_PAD_L_04LOD0.SetActive(false); break; } } } public void SetBodyType(Toggle id) { try { PC.BODY_TYPE name = (PC.BODY_TYPE)Enum.Parse(typeof(PC.BODY_TYPE), id.name, true); if(id.isOn) { this.PC_CC.selectedBodyType = name; Debug.Log(string.Format("{0} was turned on", name)); } else { this.PC_CC.selectedBodyType = PC.BODY_TYPE.normal; Debug.Log(string.Format("{0} was turned off", name)); } } catch { // if the value passed is not in the enumeration set it to none this.PC_CC.selectedBodyType= PC.BODY_TYPE.normal; Debug.Log("Body Type Enumeration Not Found!"); } switch (id.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12633)
Hello! Python by Anthony Briggs(9946)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9818)
The Mikado Method by Ola Ellnestam Daniel Brolund(9810)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(9623)
Dependency Injection in .NET by Mark Seemann(9367)
Hit Refresh by Satya Nadella(8850)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8331)
The Kubernetes Operator Framework Book by Michael Dame(7882)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7808)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7787)
Grails in Action by Glen Smith Peter Ledbrook(7719)
Exploring Deepfakes by Bryan Lyon and Matt Tora(7665)
Practical Computer Architecture with Python and ARM by Alan Clements(7606)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7590)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(7576)
Robo-Advisor with Python by Aki Ranin(7560)
Building Low Latency Applications with C++ by Sourav Ghosh(7446)
Svelte with Test-Driven Development by Daniel Irvine(7426)
